package com.rem.designPattern.decorator装饰者;

import java.math.BigDecimal;

/**
 * 快餐类和具体快餐
 *
 * @author Rem
 * @date 2022-11-17
 */
public abstract class FastFood {
    private String name;
    private BigDecimal price;

    /**
     * 计算价格
     *
     * @return
     */
    public abstract BigDecimal cost();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public FastFood(BigDecimal price) {
        this.price = price;
    }

    public FastFood(String name, BigDecimal price) {
        this.name = name;
        this.price = price;
    }
}

class FriedRice extends FastFood {

    public FriedRice() {
        super("炒饭", new BigDecimal(15));
    }

    @Override
    public BigDecimal cost() {
        return getPrice();
    }
}

class FriedNoodles extends FastFood {

    public FriedNoodles() {
        super("炒面", new BigDecimal(10));
    }

    @Override
    public BigDecimal cost() {
        return getPrice();
    }
}